package com.demo.web.valid;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
 * 自定义校验注解Demo
 * 
 * @author baihe
 * @date 2023/07/20
 */
public class NoBlankValidator implements ConstraintValidator<NoBlank, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        // null 不做检验
        if (value == null) {
            return true;
        }
        // 校验失败
        return !value.contains(" ");
        // 校验成功
    }
}
